package com.songlanyun.modules.disabilityauth.controller.admin;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.songlanyun.modules.disabilityauth.model.DisabilityAuditDTO;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.songlanyun.modules.disabilityauth.entity.DisabilityAuthEntity;
import com.songlanyun.modules.disabilityauth.service.DisabilityAuthService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;



/**
 * 残疾认证
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2022-07-19 14:47:49
 */
@RestController
@RequestMapping("admin/disabilityauth")
public class DisabilityAuthController extends AbstractController {
    @Autowired
    private DisabilityAuthService disabilityAuthService;


    /**
     * 审核
     */
    @PostMapping("/audit")
    //@RequiresPermissions("disabilityauth:disabilityauth:save")
    public R audit(@RequestBody DisabilityAuditDTO dto){
        dto.setAuditAdmin(getUser().getUsername());
        disabilityAuthService.audit(dto);
        return R.ok();
    }


    /**
     * 获取申请
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("disabilityauth:disabilityauth:info")
    public R info(@PathVariable("id") Long id){
        DisabilityAuthEntity disabilityAuth = disabilityAuthService.loadById(id,false);
        return R.ok().put("data", disabilityAuth);
    }



    /**
     * 列表
     * real_name
     * mobile
     * status (-1或不传,0待审核，1审核通过，2审核不通过)
     */
    @RequestMapping("/page")
    //@RequiresPermissions("disabilityauth:disabilityauth:list")
    public R page(@RequestParam Map<String, Object> params){
        PageUtils page = disabilityAuthService.queryPage(params);
        return R.ok().put("page", page);
    }




    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("disabilityauth:disabilityauth:update")
    public R update(@RequestBody DisabilityAuthEntity disabilityAuth){
		disabilityAuthService.updateById(disabilityAuth);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("disabilityauth:disabilityauth:delete")
    public R delete(@RequestBody Long[] ids){
		disabilityAuthService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
